package com.ittest.server.impl;

import com.ittest.server.SendMailServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;


//@Service  //简单邮件实现
public class SendMailServerImpl implements SendMailServer {

    @Autowired
    private JavaMailSender javaMailSender;


    //发送人
    private String form = "1021854489@qq.com";
    //接收人
    private String to = "17331988610@163.com";
    //标题
    private String subject = "测试邮件";
    //正文
    private String context = "测试邮件正文";
    @Override
    public void sendmail() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(form+"(杨闯杰)");//加上后面的字符串，这样在接收者邮箱就会替代显示为发件人信息
        message.setTo(to);
        message.setSubject(subject);
        message.setText(context);
        javaMailSender.send(message);

    }
}
